package com.emellend.api.t;

import com.emellend.api.R;

import android.app.Activity;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.TextSwitcher;
import android.widget.TextView;
import android.widget.ViewSwitcher.ViewFactory;

public class TextSwitcher1 extends Activity implements ViewFactory,OnClickListener {
	
	private TextSwitcher mSwitcher;
	private int mCounter=0;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.text_switcher_1);
		init();
		
	}
	private void init() {
		mSwitcher = (TextSwitcher) this.findViewById(R.id.switcher);
		mSwitcher.setFactory(this);
		
		Animation in=AnimationUtils.loadAnimation(this, android.R.anim.fade_in);
		Animation out=AnimationUtils.loadAnimation(this, android.R.anim.fade_out);
		
		mSwitcher.setInAnimation(in);
		mSwitcher.setOutAnimation(out);
		
		this.findViewById(R.id.next).setOnClickListener(this);
		
		updateCounter();
	}
	private void updateCounter() {
		 mSwitcher.setText(String.valueOf(mCounter));
	}
	public View makeView() {
		 TextView t = new TextView(this);
	     t.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL);
	     t.setTextSize(36);
	     return t;
	}
	public void onClick(View v) {
		mCounter++;
		updateCounter();
	}

}
